class EventparticipantsController < ApplicationController
	
  # GET /eventparticipants
  # GET /eventparticipants.xml
  def index
    @eventparticipants = Eventparticipant.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @eventparticipants }
    end
  end

  # GET /eventparticipants/1
  # GET /eventparticipants/1.xml
  def show
    @eventparticipant = Eventparticipant.find(params[:id])
    @dataevent = Event.find_all_by_id(@eventparticipant.event_idf)
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @eventparticipant }
    end
  end

  # GET /eventparticipants/new
  # GET /eventparticipants/new.xml
  def new
  	@event = Event.find_by_id(params[:id])
    @eventparticipant = Eventparticipant.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @eventparticipant }
    end
  end

  # GET /eventparticipants/1/edit
  def edit
    @eventparticipant = Eventparticipant.find(params[:id])
  end

  # POST /eventparticipants
  # POST /eventparticipants.xml
  def create
    @eventparticipant = Eventparticipant.new(params[:eventparticipant])
    respond_to do |format|
      if @eventparticipant.save
        flash[:notice] = 'Evento-Participante creado satisfactoriamente.'
        format.html { redirect_to(@eventparticipant) }
        format.xml  { render :xml => @eventparticipant, :status => :created, :location => @eventparticipant }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @eventparticipant.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /eventparticipants/1
  # PUT /eventparticipants/1.xml
  def update
    @eventparticipant = Eventparticipant.find(params[:id])
    respond_to do |format|
      if @eventparticipant.update_attributes(params[:eventparticipant])
        flash[:notice] = 'Evento-Participante creado satisfactoriamente.'
        format.html { redirect_to(@eventparticipant) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @eventparticipant.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /eventparticipants/1
  # DELETE /eventparticipants/1.xml
  def destroy
    @eventparticipant = Eventparticipant.find(params[:id])
    @eventparticipant.destroy
    respond_to do |format|
      format.html { redirect_to(eventparticipants_url) }
      format.xml  { head :ok }
    end
  end
end
